<!DOCTYPE html>
<html xmlns:="http://www.w3.org/1999/xhtml" ang="en">
<head>
    <meta charset="text/html; charset=utf-8" http-equiv="content-type">
    <title>talk</title>
    <script type="text/javascript">
        var socket;
        if (!window.WebSocket) {
            whindow.WebSocket = window.MozWebSocket;
        }
        if (window.WebSocket) {
            socket = new WebSocket("ws://localhost:8081/ws");
            socket.onmessage = function (event) {
                var ta = document.getElementById('responseText');
                ta.value += event.data + "\r\n";
            };
            socket.onopen = function (event) {
                var ta = document.getElementById('responseText');
                ta.value = "connected！";
            };
            socket.close = function (event) {
                var ta = document.getElementById('responseText');
                ta.value = "closed!";
            };
        } else {
            alert("your webTool not support WebSocket context");
        }

        function send(message) {
            if (!window.WebSocket) {
                return;
            }
            if (socket.readyState == WebSocket.OPEN) {
                socket.send(message);
            } else {
                alert("WeSocket does't connected !")
            }
        }
    </script>
</head>
<body>
<form onsubmit="return false;">
    <hr color="black"/>
    <h3>send message from client</h3>
    <label>name</label><input type="text" name="uid" value="runbird"><br/>
    <label>name</label><input type="text" name="message" value="hello netty"><br/>
    <br/> <input type="button" value="click send message"
                 onClick="send(this.form.uid.value+':'+this.form.message.value)"/>
    <h3>response from server</h3>
    <textarea id="responseText" style="width: 900px;height: 300px;"></textarea>
</form>
</body>
</html>